package multithreaded;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.concurrent.ExecutionException;

public class Multi_main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws ExecutionException 
	 * @throws InterruptedException 
	 */
	public static void main(String[] args) throws IOException, InterruptedException, ExecutionException 
	{
		/*Initialisation*/
		Double result;
		MonteCarlom mc = new MonteCarlom();
		long t_end;
		long t_start;
		long time;
		ArrayList<SetOfArguments> sets=new ArrayList<SetOfArguments>();
		
		/*Read the files with sets of arguments*/
		sets=mc.load();
		
		/*Compute with Montecarlo*/
		System.out.println("Start");
		t_start=System.currentTimeMillis();

		result=mc.monteCarloCalculation(sets.get(0).getCallPutFlag(),sets.get(0).getS(),sets.get(0).getX(),sets.get(0).getT()
		,sets.get(0).getR(),sets.get(0).getB(),sets.get(0).getV(),sets.get(0).getnSteps(),sets.get(0).getnSimulations());
		
		t_end=System.currentTimeMillis();
		
		/*Print out the results*/
		time=t_end-t_start;
		System.out.println("Time : "+time+" milliseconds");
		System.out.printf("Result : %.4f",result);
	}
}